var myDialog;
function formToken(){
	var forms = $("form");
	for(var i=0;i<forms.length;i++){
		createToken(forms[i]);
	}
}
function createToken(form){
	var element = document.createElement("input");
	element.id = "FORM_TOKEN";
	element.name = "FORM_TOKEN";
	element.type = "hidden";
	element.value = createRadom();
	form.appendChild(element);
}
function createRadom(){
	var radonNum1 = Math.floor(Math.random()*1000);
	var radonNum2 = Math.floor(Math.random()*1000);
	return radonNum1+new Date().getTime()+radonNum2;
}
function filterInterString(msg){
	var message = msg.replace("<script type=\"text/javascript\" charset=\"UTF-8\">","").replace("</script>","");
	var i=message.indexOf("window");
	if(i!=-1)
		return message.substring(7,i-3);
	return message.substring(7,message.length-3);
}
function filterAlert(data){
	 try{
		 if(data.indexOf("<body>")==-1){
			 if(data.indexOf("</script>")!=-1){
				 if(myDialog!=undefined){
					 try{
					  	myDialog.close();
					 }catch(e){}
				 }
				art.dialog({
					icon : 'warning',
					content : filterInterString(data),
					lock : true
				});
				return false;
			 }else{
				 return true;
			 }
		 }else if(data.indexOf("seContent")!=-1){
			 if(myDialog!=undefined){
				 try{
				  	myDialog.close();
				 }catch(e){}
			 }
			 art.dialog({
					icon : 'warning',
					content : $(data).text(),
					lock : true
				});
			 return false;
		 }else{
			 return true;
		 }
	  }catch (e){
		  if(data.success!='succeed'){
			  if(myDialog!=undefined){
					 try{
					  	myDialog.close();
					 }catch(e){}
				 }
			  		art.dialog({
						icon : data.success,
						content : data.message,
						lock : true
					});
				 return false;
			 }else {
				 return true;
			 }
	  }
}